package hn.cch.grammar.gc;

/**
 * 线程状态
 */
public class ThreadStatusDemo {

    public static void main(String[] args) {

        // busy:RUNNABLE
        final boolean busy = true;
        new Thread(new Runnable() {
            @Override
            public void run() {
                while (busy) {
                    // code
                }
            }
        }, "thread-busy").start();


        // lock:WAITING
        final Object lock = new Object();
        new Thread(new Runnable() {
            @Override
            public void run() {
                synchronized (lock) {
                    try {
                        lock.wait();
                    } catch (InterruptedException e) {
                        System.out.println(e.getMessage());
                    }
                }
            }
        }, "thread-lock").start();


    }

}
